package com.cuitrip.apiservice;

import com.cuitrip.apiservice.model.ApiManager;
import com.cuitrip.util.LocationUtil;
import com.cuitrip.util.NetworkUtil;
import com.lab.network.model.CtApiRequest;
import com.lab.network.model.CtRemoteBusiness;
import com.lab.network.model.ParseType;
import com.lab.network.proxy.ApiProxy;

import java.util.HashMap;


public class TrackBusiness {

    public enum Action{
        CLICK("click"),
        ADDLIKE("addLike"),
        DISLIKE("disLike"),
        SEARCH("search"),
        REVIEW("review");

        public String actionName;



        Action(String actionName) {
            this.actionName = actionName;
        }
    }

    public enum Source{
        RECOMMEND("recommend"),
        SERVICE_LIST("serviceList"),
        HOT_SEARCH("hotsearch"),
        SERVICE_DETAIL("serviceDetail");

        public String sourceName;

        Source(String sourceName) {
            this.sourceName = sourceName;
        }
    }

    public static final String PAGE = "page";
    public static final String OP = "op";
    public static final String OPERATION_INDXE = "opIndex";
    public static final String ITEM_ID = "itemIds";
    public static final String SOURCE =  "source";
    public static final String KEY_WORD = "keyWord";
    public static final String HOT_WORD = "hotWord";



    public static void request(ApiProxy apiProxy,
                                               HashMap<String,Object> dataParams) {
        CtApiRequest ctApiRequest = new CtApiRequest();
        ctApiRequest.setApiName(ApiManager.UPLOAD_STATISTIC_DATA);
        ctApiRequest.addParam("ip", NetworkUtil.getIPAddress());
        ctApiRequest.addParam("lat", LocationUtil.getLocation().first);
        ctApiRequest.addParam("lng", LocationUtil.getLocation().second);
        if (dataParams != null){
            for (String key:dataParams.keySet()){
                ctApiRequest.addParam(key,dataParams.get(key));
            }
        }
        CtRemoteBusiness ctRemoteBusiness = new CtRemoteBusiness(ctApiRequest);
        apiProxy.postAsync(ctRemoteBusiness, new ParseType());
    }

}
